using GLib;

public class Giocmd.PanelFile : Object {
	public bool selected;
	public bool parent_directory_link;
	
	private FileInfo file_info {get;set;}

	public static int NameCompareFunc (PanelFile a, PanelFile b)
	{
		if (a.directory != b.directory)
		{
			return (int)b.directory - (int)a.directory;
		}
		else {
			if (a.name.casefold () < b.name.casefold ()) {
				return -1;
			} else if (a.name.casefold () == b.name.casefold ()) {
				return 0;
			} else {
				return 1;
			}
		}
	}
	
	public static int SizeCompareFunc (PanelFile a, PanelFile b)
	{
		if (a.directory != b.directory)
		{
			return (int)b.directory - (int)a.directory;
		}
		else {
			if ( a.size < b.size ) {
				return -1;
			} else if (a.size > b.size) {
				return 1;
			} else {
				return 0;
			}
		}
	}

	public string name {
		get {
			if (parent_directory_link)
				return "..";
			return file_info.get_name ();
		}
	}
	
	public uint64 size {
		get { 
			return file_info.get_size ();
		}
	}
	
	public bool directory {
		get {
			return (file_info.get_file_type () & FileType.DIRECTORY) != 0;
		}
	}
	
	public PanelFile (FileInfo file_info)
	{
		this.file_info = file_info;
	}

	
}
